package com.github.aloxc.plugin.restplus.listener;

import com.github.aloxc.plugin.restplus.i18n.I18Bundle;
import com.github.aloxc.plugin.restplus.i18n.I18Config;
import com.github.aloxc.plugin.restplus.popup.PopupBalloon;
import com.intellij.openapi.project.Project;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
 *
 * @author leero
 */
public class SelectLanguageListener implements ActionListener {
    private String local ;
    private Project project;

    public SelectLanguageListener(String local,Project project){
        this.local = local;
        this.project = project;
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        I18Config i18Config = new I18Config();
        if (!local.equals(i18Config.getLocale())) {
            i18Config.toggleLanguage(local);
            PopupBalloon.showNotification(project,I18Bundle.getMessage("com.github.aloxc.plugin.restplus.switch_language.text.success"),true);
        }
    }
}
